<?PHP
  $current_page = "user_delete.php";
  $page_type = "A";
  require_once 'header.php';
?>
	<div id="page">
	  <div id="page-padding">
        <!-- start content -->	    
	    <div id="content">
	      <div id="content-padding">
            <h1>Account Deletion Confirmation</h1>
            <?PHP
              $input_user_id = $_GET["user_id"];

              // Fetch the account to be deleted and display it
              $sql = "select UserId, Fname, Lname, AFlag, SFlag, VFlag from USER_ACCT where UserId='$input_user_id'";

              $result_array = execute_sql_in_oracle($sql);
              $result = $result_array["flag"];
              $cursor = $result_array["cursor"];

              if (!$result) {
                $delete_error = 'User account('."<b><font color=\"black\">".$input_user_id."</font></b>".') query failed!';
                echo "'<p>'.$delete_error.'</p>'";
                echo("<br><form method=\"post\" action=\"user.php\">
                      <input type=\"submit\" value=\"Go Back\">
                      </form>");
              }
              // Try to get user account information from database query result
              else if (!($values = oci_fetch_array($cursor))) {
                // Account already deleted by a separate session
                $delete_error = 'User account('."<b><font color=\"black\">".$input_user_id."</font></b>".') has already been deleted by a separate session';
                echo "'<p>'.$delete_error.'</p>'";
                echo("<br><form method=\"post\" action=\"user.php\">
                      <input type=\"submit\" value=\"Go Back\">
                      </form>");
              }
              else {
                oci_free_statement($cursor);

                $user_id = $values[0];
                $fname = $values[1];
                $lname = $values[2];
                $aflag = $values[3];
                $sflag = $values[4];
                $vflag = $values[5];
  
                if ($aflag == 'y')
                  $account_type = "Administrator";
                else if ($sflag == 'y') 
                  $account_type = "Stakeholder";
                else if ($vflag == 'y')
                  $account_type = "Volunteer";
                else 
                  $account_type = "";

                // Display the account to be deleted
                echo("<form method=\"post\" action=\"user_delete_response.php\">
                      Username(Read-only): <input type=\"text\" readonly value = \"$user_id\" size=\"20\" maxlength=\"30\" name=\"user_id\"> <br />
                      Account Type: <input type=\"text\" disabled value = \"$account_type\" size=\"20\" maxlength=\"30\" name=\"account_type\">  <br />  
                      First Name: <input type=\"text\" disabled value = \"$fname\" size=\"20\" maxlength=\"30\" name=\"fname\">  <br />
                      Last Name: <input type=\"text\" disabled value = \"$lname\" size=\"20\" maxlength=\"30\" name=\"lname\">  <br />");

                echo("<input type=\"submit\" value=\"Delete\">
                      </form><br><br><br><br>
                      <form method=\"post\" action=\"user.php\">
                      <input type=\"submit\" value=\"Go Back\">
                      </form>");
              }
          ?>
	      </div>
		</div>
	  <!-- end content --></div>
	  <div id="footer">
	    <div id="footer-pad">
	      <div class="line"></div>
		  <!-- footer and copyright notice -->
	      <p>Design by <a href="http://www.steves-templates.com">Steve's free website templates</a>.</p>
		  <!-- end footer and copyright notice -->
	    </div>
	  </div>
	</div>
  </body>
</html>